package com.yiwei.zhh.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yiwei.zhh.R;
import com.yiwei.zhh.api.bean.KeyValueBean;
import com.yiwei.zhh.constant.Const;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by xsooy-pc on 2017/5/19.
 * 验证成功界面
 */

public class AutonymSuccessActivity extends BaseActivity {
    @BindView(R.id.txt_tips)
    TextView txtTips;
    @BindView(R.id.txt_left_one)
    TextView txtLeftOne;
    @BindView(R.id.txt_right_one)
    TextView txtRightOne;
    @BindView(R.id.txt_left_two)
    TextView txtLeftTwo;
    @BindView(R.id.txt_right_two)
    TextView txtRightTwo;
    @BindView(R.id.txt_left_three)
    TextView txtLeftThree;
    @BindView(R.id.txt_right_three)
    TextView txtRightThree;
    @BindView(R.id.layout_three)
    RelativeLayout layoutThree;
    private Unbinder unbinder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBaseContentView(R.layout.activity_identity_success);
        unbinder = ButterKnife.bind(this);
        baseInitView(this, "AutonymSuccessActivity", Const.ViewType.ACTIVITY);
        initView();
    }

    private void initView() {
        setBackIntent();
        Intent data = getIntent();
        ArrayList<KeyValueBean> infos = data.getParcelableArrayListExtra("info");
        if (data.getStringExtra("type").equals(Const.AutonymTypes.education)) {
//            String xuex_school = data.getStringExtra("xuex_school");
//            String xuex_major = data.getStringExtra("xuex_major");
            setTitleText("学信认证");
            txtTips.setText("你已通过学信认证");
        } else if (data.getStringExtra("type").equals(Const.AutonymTypes.mobile)) {
//            String mobile = data.getStringExtra("mobile");
//            String name = data.getStringExtra("name");
//            txtLeftOne.setText("手机号");
//            txtLeftTwo.setText("手机实名");
//            txtRightOne.setText(mobile);
//            txtRightTwo.setText(name);
            setTitleText("运营商认证");
            txtTips.setText("你已通过运营商认证");
        } else if (data.getStringExtra("type").equals(Const.AutonymTypes.taobao)) {
//            String username = data.getStringExtra("username");
//            String nickName = data.getStringExtra("nickName");
//            txtLeftOne.setText("淘宝账号");
//            txtLeftTwo.setText("淘宝昵称");
//            txtRightOne.setText(username);
//            txtRightTwo.setText(nickName);

            setTitleText("淘宝认证");
            txtTips.setText("你已通过淘宝认证");
        }
        if (infos == null || infos.size() == 0) {
            return;
        }
        for (int i = 0; i < infos.size(); i++) {
            if (i == 0) {
                txtLeftOne.setText(infos.get(0).key);
                txtRightOne.setText(infos.get(0).value);
            } else if (i == 1) {
                txtLeftTwo.setText(infos.get(1).key);
                txtRightTwo.setText(infos.get(1).value);
            } else if (i == 2) {
                txtLeftThree.setVisibility(View.VISIBLE);
                txtRightThree.setVisibility(View.VISIBLE);
                txtLeftThree.setText(infos.get(2).key);
                txtRightThree.setText(infos.get(2).value);
            }
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }
}
